namespace GuestBook.DataContext.Migrations
{
    using GuestBook.Model;
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    internal sealed class Configuration : DbMigrationsConfiguration<GuestBook.DataContext.GuestBookDb>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
            MigrationsDirectory = @"DataContext\Migrations";
        }

        protected override void Seed(GuestBook.DataContext.GuestBookDb context)
        {
            //  This method will be called after migrating to the latest version.

            string lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
            for (int i = 0; i < 71; i++)
            {
                context.GuestBookRecords.AddOrUpdate(r => r.Text, new GuestBookRecordModel()
                {
                    UserName = String.Format("{0}-UserName", Utils.RandomNumber(0, 30)),
                    HomePageUrl = String.Format("http://www.example.{0}.com", Utils.RandomNumber(0, 30)),
                    Email = String.Format("{0}@example.com", Utils.RandomNumber(0, 30)),
                    CreatedAt = new DateTime(2015, 3, Utils.RandomNumber(1, 30), 21, 45, 17, DateTimeKind.Utc),
                    Text = String.Format("#{0}. {1}", i, lorem)
                });
            }
        }
    }
}
